package com.analytical.www.fargment

import android.os.Bundle
import com.analytical.www.MainActivity
import com.analytical.www.R
import com.analytical.www.base.FragmentBase
import com.analytical.www.databinding.FragSettingBinding

/**
 *@Auther Shawn
 *创建时间：2023/12/24 12:34
 */
class FragSetting:FragmentBase() {
    private lateinit var binding:FragSettingBinding
    override fun getLayoutId(): Int {
        return R.layout.frag_setting
    }

    override fun lazyLoad() {
        binding = FragSettingBinding.bind(contentView)
    }

    private fun changeTitle(title:String){
        if (context is MainActivity) {
            (context as MainActivity).changeTitle(title)
        }
    }

    override fun getData() {
        vmData?.taskLiveData?.observe(this){
            binding.includeTestSetting.btn1.text = "样品名称\n${it.name}"
        }
    }

    override fun initClick() {
        binding.includeTestSetting.btn1.setOnClickListener{
            if (context is MainActivity) {
                (context as MainActivity).showFullScreenFrag(FragSampleInput.newInstance())
            }
        }
    }

    override fun onKeyCodeBack(): Boolean {
        return false
    }

    private fun close() {
        if (context is MainActivity) {
            (context as MainActivity).removeFullScreenFrag(FragSetting::class.java.name)
        }
    }

    companion object{
        fun newInstance(): FragSetting {
            val args = Bundle()
            val fragment = FragSetting()
            fragment.arguments = args
            return fragment
        }
    }
}